const Router = require('koa-router');
const router = new Router();
const bodyparser = require('koa-bodyparser')
const MessageCenter = require('../entiity/MessageCenter');

//调用中间件，拿到前端post数据
router.use(bodyparser());


router.post('/create', async (ctx)=>{
  //得到房间号和用户名
  const userName = ctx.request.body.userName;
  const roomId = (new Date()).getTime().toString().slice(-6);
  //创建messageCenter实例
  const messageCenter = new MessageCenter(ctx);
  await messageCenter.regist(roomId, userName);
})

module.exports = router;